package com.hmall.search.web;

import com.hmall.feign.dto.PageDTO;
import com.hmall.search.pojo.ItemDoc;

import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 黎明 on 2023/1/7
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ISearchService searchService;

    //自动补全
    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return searchService.suggestion(key);
    }

    //动态过滤条件
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams params){
        return searchService.filters(params);
    }

    //商品搜索
    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params){
        return searchService.search(params);
    }

}
